/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

package com.querie.test;

import com.querie.collab.CosineItemSimilarity;
import com.querie.collab.ItemSimilarity;
import com.querie.collab.JacItemSimilarity;
import com.querie.util.QryParameters;

/**
 *
 * @author Duc On <ductuanon@hotmail.com>
 */
public class ThreadTopK extends Thread {

    public void run() {
        try {
            ItemSimilarity sim = null;
            long start = System.currentTimeMillis();
            QryParameters qParam = QryParameters.getInstance();
            qParam.setValue("TOPKTIME", "0");
            String algoType = qParam.getValue("ALGO");
            if (algoType.equals("jac")) {
                sim = new JacItemSimilarity();
            } else if (algoType.equals("cos")) {
                sim = new CosineItemSimilarity();
            } else {
                throw new Exception("Unknown Algorithm");
            }
            sim.selectKSimItem();
            sim.close();
            //new TestHarnessButtonStatus().enableAllButtons();
            QryParameters.getInstance().enableAllButtons();
            long elapsedTimeMillis = System.currentTimeMillis() - start;
            long elapsedTimeSec = elapsedTimeMillis / 1000;
            QryParameters.getInstance().setValue("TOPKTIME", "" + elapsedTimeSec);
            System.out.println("%%%%%%%%%%%%%%%%%%%Time taken for TopK = " + elapsedTimeSec + " sec");
        } catch(Exception ex) {
            ex.printStackTrace();
        }
    }
}
